#
#        Python GUI - Applications - Swing
#

import GApplications
from GApplications import application, Application as GApplication

import java.awt.datatransfer as datatransfer
import java.awt as awt

from JHacks import *

_j_stringFlavor=datatransfer.DataFlavor.stringFlavor

class _j_StringClipboardContents(datatransfer.Transferable):
    def __init__(self,string):
        self.string=unicode(string)
    
    def getTransferData(self,flavor):
        return self.string
    
    def getTransferDataFlavors(self):
        return [_j_stringFlavor]
    
    def isDataFlavorSupported(self,flavor):
        return (flavor==_j_stringFlavor)

class Application(GApplication):
    
    __clipboard=None
    
    def handle_next_event(self,modal_window=None):
        pass
    
    def zero_windows_allowed(self):
        return True
    
    def query_clipboard(self):
        return not not self.get_clipboard()
    
    def get_clipboard(self):
        if not self.__clipboard: self.__clipboard=awt.Toolkit.getDefaultToolKit().getSystemClipboard()
        return self.__clipboard.getContents(self).getTransferData(_j_stringFlavor)

    def set_clipboard(self,x):
        if not self.__clipboard: self.__clipboard=awt.Toolkit.getDefaultToolKit().getSystemClipboard()
        self.__clipboard.setContents(_j_StringClipboardContents(x),self)
    